<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>进货录入</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="<%=request.getScheme() + "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath() + "/"%>css/bootstrap.min.css">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="<%=request.getScheme() + "://" + request.getServerName() + ":" +
                request.getServerPort() + request.getContextPath() + "/"%>js/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="<%=request.getScheme() + "://" + request.getServerName() + ":" +
                request.getServerPort() + request.getContextPath() + "/"%>js/bootstrap.min.js"></script>
</head>

<body>
<div style="padding:0px; margin:0px;">
    <ul class="breadcrumb" style="  margin:0px; " >
        <li>进货管理</li>
        <li>进货录入</li>
    </ul>
</div>
<form action="http://localhost:8080/supermarket/ProductInputServlet" class="form-horizontal">
    <h5 class="page-header alert-info" style="padding:10px; margin:0px; margin-bottom:5px;">基本信息${error}</h5>

    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品条码</label>
                <div class="col-sm-9">
                    <input type="text" name="bar_code" id="barcode" value="${inputProductPurchase.getBar_code()}" class="form-control input-sm"  />
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">商品名称</label>
                <div class="col-sm-9">
                    <input type="text" name="product_name" id="name" value="${inputProductPurchase.getProduct_name()}" class="form-control input-sm" />
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">进货单价</label>
                <div class="col-sm-9">
                    <input type="text" id="price" name="purchase_price" value="${inputProductPurchase.getPurchase_price()}" class="form-control input-sm" />
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">进货日期</label>
                <div class="col-sm-9">
                    <input type="date" id="purchase_date" name="purchase_date" class="form-control input-sm" />
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">生产日期</label>
                <div class="col-sm-9">
                    <input type="date" id="pro_date" name="pro_date" class="form-control input-sm" />
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">保质日期</label>
                <div class="col-sm-9">
                    <input type="date" id="exp_date" name="exp_date" class="form-control input-sm" />
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">进货数量</label>
                <div class="col-sm-9">
                    <input type="text" id="count" name="count" value="${inputProductPurchase.getCount()}" class="form-control input-sm" />
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">销售单价</label>
                <div class="col-sm-9">
                    <input type="text" id="sale_price" name="sale_price" value="${inputProductPurchase.getSale_price()}" class="form-control input-sm" />
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <!--开始 -->
    <div class="row">
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">供应商</label>
                <div class="col-sm-6">
                    <select name="supplier_name" class="form-control input-sm">
                        <c:forEach items="${SupplierName}" var="SupplierName">
                            <option value="${SupplierName.getSupplier_name()}">${SupplierName.getSupplier_name()}</option>
                        </c:forEach>


                    </select>
                </div>
            </div>
        </div>
        <div class="col-sm-5">
            <div class="form-group">
                <label class="col-sm-3 control-label">所属品类</label>
                <div class="col-sm-6">
                    <select name="category_name" class="form-control input-sm">
                        <c:forEach items="${CategoryName}" var="CategoryName">
                            <option value="${CategoryName.getCategory_name()}">${CategoryName.getCategory_name()}</option>
                        </c:forEach>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <!--结束 -->
    <div class="row">
        <div class="col-sm-3 col-sm-offset-4">
            <input  type="submit" class="btn btn-success" value="提交"/>
            <input  type="reset" class="btn btn-success" value="重置"/>
        </div>
    </div>
</form>

<script>
    $("#barcode").blur(
        function(){
        $.post("http://localhost:8080/supermarket/ProductOntServlet",
            {
                bar_code:$("#barcode").val()
            },
            function (data) {
                $("#name").val(data.product_name);
                $("#price").val(data.purchase_price);
                $("#sale_price").val(data.sale_price);
                alert("存在相同信息！可更改");
            },"json")});
</script>
</body>
</html>
